/**
*
*/
var t = '';
var tn = null;
var tu = undefined;
var tns = 'null';
var tus = 'undefined';
var toast = {};
var tz = 0;
var obj = {"cid":"C0","ctext":"区县","ctext1":"","ctext2":null};
var arr = [obj,obj,obj,null,obj]
var toast;
$(function () {
  test();
  toast = new Toast();
  toast.show('欢迎回来');
  toast.test();

  // console.log(ObjNullValueReplace(arr,'-'));
});

// /* toast */
// function Toast() {
//
// }
// Toast.prototype = {
//   ele:'',
//   eleHtml:'<div id="toast" class="toast"><div class="toast-icon margin-bottom-15 active"></div><div class="toast-text"></div></div>',
//   icon:'active',
//   text:'默认提示',
//   duration:2000,
//   timeoutId:0,
//   aurhor:'emoker',
//   test: function () {
//     console.log("Toast from "+this.aurhor);
//     // console.log('{"ele":"'+this.ele+'","icon":"'+this.icon+'","text":"'+this.text+'","duration":"'+this.duration+'","timeoutId":"'+this.timeoutId+'","aurhor":"'+this.aurhor+'"}')
//   },
//   init:function(ele){
//     this.ele = ele;
//     if ($('.toast').length == 0 && $('#toast').length == 0) {
//       $('body').append(this.eleHtml);
//     }
//     console.log('Toast initial complete.');
//   },
//   set:function (t,i,d) {
//     var icon = i || this.icon;
//     var text = t|| this.text;
//     var duration = d|| this.duration;
//     var ele = this.ele || "toast";
//     ele = "#"+ele;
//     if($('.toast').length == 0 && $('#toast').length == 0){
//       this.init();
//     }
//     $(ele).find('>.toast-icon').addClass(icon);
//     $(ele).find('>.toast-text').html(text);
//     var _this = this;
//     clearTimeout(this.timeoutId);
//     this.timeoutId = setTimeout(function () { _this.hide(); },duration);
//   },
//   show:function (t,i,d) {
//     this.set(t,i,d);
//     var ele = this.ele || "toast";
//     ele = "#"+ele;
//     $(ele).addClass('active');
//   },
//   hide: function () {
//     var ele = this.ele || "toast";
//     ele = "#"+ele;
//     clearTimeout(this.timeoutId);
//     $(ele).removeClass('active');
//   },
// };
//
// /* toast end */

function ObjNullValueReplace(obj,replace) {
  if (typeof(obj) != 'object') {
    return NullValueReplace(obj,replace);
  }
  for(var i in obj){
    if(typeof(obj[i]) != 'object'){
      obj[i] = NullValueReplace(obj[i],replace);
    }else{
      obj[i] = ObjNullValueReplace(obj[i],replace);
    }
  }
  return obj;
}
function NullValueReplace(val,replace) {
  if (isNullOrUndefined(val)) {
    return replace;
  }
  return val;
}
function isNullOrUndefined(exp) {
  if (exp === 0) {
    return false;
  }
  // if (!exp && typeof(exp)!='undefined' )
  if (!exp )
  {
    return true;
  }else {
    return false;
  }
}
